package org.github.manx98.jlibhac.crypto;

import cn.hutool.core.util.HexUtil;

/**
 * @author Manx98
 * @version 1.0
 * @since 2022/10/2 23:37
 */
public class AesKey {
    public final int Length;
    private final byte[] data;

    public AesKey() {
        this(0x10);
    }

    public AesKey(int length) {
        this.Length = length;
        this.data = new byte[this.Length];
    }

    public AesKey(int length, byte[] data) {
        Length = length;
        this.data = data;
    }

    public void storeFromHex(String hex) {
        byte[] bytes = HexUtil.decodeHex(hex);
        System.arraycopy(bytes, 0, this.data, 0, bytes.length);
    }

    public boolean isZeros() {
        return (data[0] | data[1]) == 0;
    }

    public byte[] getData() {
        return data;
    }
}
